/** bcmi_frame job scheduler
 *
 *  bcmi_frame job scheduler
 *
 *  @author : huicong
 *  @date : 2008-10-29
 *
 */

#ifndef _JOB_SYSTEM_H
#define _JOB_SYSTEM_H

#include "BasicHeader.h"
#include "ParallelFrame.h"
#include "FrameJob.h"

#include <vector>

namespace bcmi_frame
{

    class JobSystem
    {
    public:

        JobSystem(_IN ParallelFrame *_frame);

        ~JobSystem();

    public:

        /** Add job into job list
         *  
         *  Add job into job list. You must not delete this before JobSystem is destroyed.
         *  In other words, these job will be executed and will be destroyed by JobSystem's destructor.
         *
         *  @param [_IN] FrameJob *_jobInstance : an instance of job.
         *  @return HRESULT : add result
         *
         */
        HRESULT addJob(_IN FrameJob *_jobInstance);

        /** return the FrameJob at _index, NULL if the _index error */
        FrameJob* jobAt(IN UINT _index);

        /** execute all job int the job list, one by one */
        HRESULT execute();

    private:
        typedef std::vector<FrameJob* > JOB_LIST;
        JOB_LIST _jobList;
        ParallelFrame *_myFrame;
    };

}; //namespace bcmi_frame

#endif //#ifndef _JOB_SYSTEM_H